{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}

module Chapter5b where
import Yesod


data App = App
mkYesod "App" [parseRoutes|
/ HomeR GET
|]

instance Yesod App where


{-
myWidget1=do
    [hamlet|<h1>My Title|]
    [lucius|h1{color:green}|]
    
myWidget2=do
    setTitle  "My Home Page"
    addScriptRemote "http://img.cankaoxiaoxi.com/js/lib/jquery.js"
    
myWidget =do
        myWidget1
        myWidget2
-}
getHomeR::Handler Html
getHomeR = defaultLayout $ do
    headerClass <- newIdent
    setTitle "toWidgetHead and toWidgetBody"
    toWidgetBody
        [hamlet|<script src=/included-in-body.js>|]
    toWidgetHead
        [hamlet|<script src=/inclued-in-head.js>|]
    toWidget
        [hamlet|<h1 .#{headerClass}>MyHeader|]
    headerClass1 <- newIdent
    toWidget
        [lucius|.#{headerClass1}{color:green;}|]






{-

page =[whamlet|
        <p>This is my page. I hope you enjoyed it.
        ^{footer}
        |]
-}
footer = do
    [hamlet|
        <footer>
            <p>That's all folks!
     |]
    [lucius|
        footer{
            font-weight: bold;
            text-align: center
        }
    |]
            
main::IO()
main = warp 3000 App